package com.huawei.hms.framework.network.restclient.hwhttp;

import com.huawei.hms.framework.common.Logger;
import java.io.IOException;

public class BuildInSubmit$AsyncSubmit implements Runnable {
    private Callback callback;
    final /* synthetic */ BuildInSubmit this$0;

    BuildInSubmit$AsyncSubmit(BuildInSubmit buildInSubmit, Callback callback) {
        this.this$0 = buildInSubmit;
        this.callback = callback;
    }

    public Submit get() {
        return this.this$0;
    }

    public void run() {
        Response response = null;
        Object obj = null;
        BuildInSubmit.access$000(this.this$0).enter();
        try {
            response = BuildInSubmit.access$100(this.this$0);
            if (this.this$0.isCanceled()) {
                throw new IOException("Canceled");
            }
            obj = 1;
            this.callback.onResponse(get(), response);
            BuildInSubmit.access$200(this.this$0).callEnd(response);
            BuildInSubmit.access$000(this.this$0).exit();
        } catch (Exception e) {
            Throwable timeoutExit = this.this$0.timeoutExit(e);
            if (response != null) {
                try {
                    response.close();
                } catch (IOException e2) {
                    Logger.w("BuildInSubmit", "close response catch IOException", timeoutExit);
                }
            }
            if (obj != null) {
                Logger.w("BuildInSubmit", "catch Exception", timeoutExit);
                return;
            }
            this.callback.onFailure(get(), timeoutExit);
            BuildInSubmit.access$200(this.this$0).callFailed(timeoutExit);
        }
    }
}
